package initialize

import (
	"base/global"
	"github.com/sirupsen/logrus"
	"os"
)

func InitLogger() {
	logger := logrus.New()
	logger.AddHook(NewContextHook())
	logger.SetFormatter(&logrus.JSONFormatter{})
	logger.SetOutput(os.Stdout)
	switch global.Config.Logger.Level {
	case "debug":
		logger.SetLevel(logrus.DebugLevel)
	case "info":
		logger.SetLevel(logrus.InfoLevel)
	case "error":
		logger.SetLevel(logrus.ErrorLevel)
	default:
		logger.SetLevel(logrus.WarnLevel)
	}
	global.Logger = logger
}
